package com.abei.gas.controller;

import cn.hutool.core.util.StrUtil;
import com.abei.gas.entity.Device;
import com.abei.gas.entity.Warehouse;
import com.abei.gas.service.WarehouseService;
import com.abei.gas.vo.DataVo;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/warehouse")
@Api(tags = "仓库管理相关接口")
public class WarehouseController {
    @Autowired
    private WarehouseService warehouseService;

    @PostMapping("/insert")
    public DataVo insert(@RequestBody Warehouse warehouse){
        warehouseService.save(warehouse);
        return DataVo.success();
    }

    @RequestMapping("/deleteById")
    public DataVo deleteById(@RequestBody List<String> ids){
        warehouseService.removeByIds(ids);
        return DataVo.success();
    }

    @RequestMapping("/update")
    public DataVo update (@RequestBody Warehouse warehouse){
        warehouseService.updateById(warehouse);
        return DataVo.success();
    }

    @GetMapping("/findAll")
    public DataVo<Warehouse> findAll(Integer page, Integer limit){
        return warehouseService.findAll(page,limit);
    }
}
